﻿var lang = new Array();
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

//function $(id) {
//	return document.getElementById(id);
//}

function $() {
    var elem = null;
    if (typeof arguments[0] != "string") {
        if (!arguments[0]) { return null; }
        elem = arguments[0];
        if (!elem["version"]) {
            $._Method.Element.apply(elem);
            if ($._appendMethod) {
                $._appendMethod.apply(elem);
            }
        }
        return elem;
    }
    var argID = arguments[0].trim();
   
    if (argID.indexOf(" ") == -1 && argID.indexOf(",") == -1 && argID.indexOf(".") == -1 && argID.indexOf("[") == -1 && argID.indexOf(">") == -1) {
        elem = document.getElementById(argID.replace("#", ""));
        if (!elem) { return null; }
        if (!elem["version"]) {
            $._Method.Element.apply(elem);
            if ($._appendMethod) {
                $._appendMethod.apply(elem);
            }
        }
        return elem;
    }
    var path = argID.replace(/(^,*)|(,*$)/g, "").split(",");
    var allelem = [];
  
    for (var a = 0, b; b = path[a]; a++) {
        var p = b = path[a].trim().replace(/ +/g, " ").split(" ");
        for (var i = 0, q; q = p[i]; i++) {
            if (q.indexOf("#") == 0) {
                if (!document.getElementById(q.substring(1))) return null;
                elem = $(q.substring(1));
                continue;
            }
            var attsel = [];
            var elem_temp = [];
            if (q.indexOf(".") != -1) {
                var tags = q.replace(/\[.*?\]/gi, function($1) { attsel.push($1.replace(/\[|\]/g, "")); return ""; });
                var tag = tags.split(".")[0];
                var cn = tags.split(".")[1];
                if (elem == null) {
                    elem_temp = $._find(tag, cn, arguments[1] || document);
                } else {
                    if (elem instanceof Array) {
                        var arr = [];
                        elem.each(function(obj) { $._find(tag, cn, obj).each(function() { arr.push(arguments[0]) }); });
                        elem_temp = arr;
                    } else {
                        elem_temp = $._find(tag, cn, elem);
                    }
                }
                elem = $._attributeSelector(attsel, elem_temp);
                continue;
            } else {
                var tag = q.replace(/\[.*?\]/gi, function($1) { attsel.push($1.replace(/\[|\]/g, "")); return ""; });
                if (elem == null) {
                    elem_temp = $A((arguments[1] || document).getElementsByTagName(tag)).each(function(obj) { $(obj) });
                } else {
                    if (elem instanceof Array) {
                        var arr = [];
                        elem.each(function(obj) { $A(obj.getElementsByTagName(tag)).each(function(obj) { arr.push($(obj)) }) });
                        elem_temp = arr;
                    } else {
                        elem_temp = $A(elem.getElementsByTagName(tag)).each(function(obj) { $(obj) });
                    }
                }
                elem = $._attributeSelector(attsel, elem_temp);
            }
        }
        if (elem.constructor == Array) {
            elem.each(function(obj) { allelem.push(obj) });
        } else {
            allelem.push(elem);
        }
        elem = null;
    }
    return allelem;
};
$.Version = "1.0.0.0";
$._find = function(tag, cn, par) {
    var arr = par.getElementsByTagName(tag || "*");
    var elem = [];
    for (var i = 0, j; j = arr[i]; i++) {
        if (j.className.hasSubString(cn, " ")) { elem.push($(j)); }
    }
    return elem;
};
$._attributeSelector = function(attsel, elem_temp) {
    for (var j = 0; j < attsel.length; j++) {
        var elemArr = [];
        var k = attsel[j].split(/=|!=/g);
        if (k.length == 1) {
            elem_temp.each(function(n) {
                if (n.getAttribute(k[0].trim())) {
                    elemArr.push(n);
                }
            });
        } else if (k.length > 1) {
            elem_temp.each(function(n) {
                if (attsel[j].indexOf("!=") != -1) {
                    if (n.getAttribute(k[0].trim()) != k[1].trim()) {
                        elemArr.push(n);
                    }
                } else {
                    if (n.getAttribute(k[0].trim()) == k[1].trim()) {
                        elemArr.push(n);
                    }
                }
            });
        }
        elem_temp.length = 0;
        elem_temp = elemArr;
    }
    return elem_temp;
};
function NameSpace() { };
function StringBuffer() { this.data = [] };
$._Method = {
    Element: function() {
        this.version = $.Version;
        this.hide = function() { this.style.display = "none"; return this };
        this.show = function() { this.style.display = ""; return this };
        this.visible = function() { this.style.visibility = "visible"; return this };
        this.hidden = function() { this.style.visibility = "hidden"; return this };
        this.getStyle = function(s) {
            var value = this.style[s == "float" ? ($.Browse.isIE() ? "styleFloat" : "cssFloat") : s.camelize()];
            if (!value) {
                if (this.currentStyle) {
                    value = this.currentStyle[s.camelize()];
                } else if (document.defaultView && document.defaultView.getComputedStyle) {
                    var css = document.defaultView.getComputedStyle(this, null);
                    value = css ? css.getPropertyValue(s) : null;
                }
            }
            return value;
        };
        this.setStyle = function(s) {
            var sList = s.split(";");
            for (var i = 0, j; j = sList[i]; i++) {
                var k = j.split(/:(?!\/\/)/g);
                var key = k[0].trim();
                key = key == "float" ? ($.Browse.isIE() ? "styleFloat" : "cssFloat") : key.camelize();
                this.style[key] = k[1].trim();
            }
            return this;
        };
        this.toggle = function() { this.getStyle("display") == "none" ? this.show() : this.hide(); return this };
        this.hasClassName = function(c) { return this.className.hasSubString(c, " "); };
        this.addClassName = function(c) { if (!this.hasClassName(c)) { this.className += " " + c }; return this };
        this.removeClassName = function(c) { if (this.hasClassName(c)) { this.className = (" " + this.className + " ").replace(" " + c + " ", " ").trim(); return this } };
        this.toggleClassName = function(c) { if (this.hasClassName(c)) { this.removeClassName(c); } else { this.addClassName(c); }; return this; };
        this.getElementsByClassName = function(c) { return this.getElementsByAttribute("className", c) };
        this.getElementsByAttribute = function(n, v) {
            var elems = this.getElementsByTagName("*");
            var elemList = [];
            for (var i = 0, j; j = elems[i]; i++) {
                var att = j[n] || j.getAttribute(n);
                if (att == v) {
                    elemList.push(j);
                }
            }
            return elemList;
        };
        this.subTag = function() { return $A(this.getElementsByTagName(arguments[0])).each(function(n) { $(n); }); };
        this.parentIndex = function(p) {
            if (this == p) { return 0 }
            for (var i = 1, n = this; n = n.parentNode; i++) {
                if (n == p) { return i; }
                if (n == document.documentElement) return -1;
            }
        };
        
        this.nextElement = function() {
            var n = this;
            for (var i = 0, n; n = n.nextSibling; i++) {
                if (n.nodeType == 1) return $(n);
            }
            return null;
        };
        this.previousElement = function() {
            var n = this;
            for (var i = 0, n; n = n.previousSibling; i++) {
                if (n.nodeType == 1) return $(n);
            }
            return null;
        };
        this.subElem = function(css) {
            return $(css, this);
        };
        this.findParent = function(p) {
            for (var i = 0, n = this; n = n.parentNode; i++) {
                if (n == document.documentElement || n == document.body) break;
                var t = 0;
                for (var key in p) {
                    var m = n.key || n[key] || n.getAttribute(key);
                    if (m != p[key]) { t++; break; }
                }
                if (t == 0) return n;
            }
            return null;
        };
    },
    Array: function() {
        this.indexOf = function() {
            for (i = 0; i < this.length; i++) {
                if (this[i] == arguments[0])
                    return i;
            }
            return -1;
        };
        this.each = function(fn) {
            for (var i = 0, len = this.length; i < len; i++) {
                fn(this[i], i);
            }
            return this;
        };
        this.sortByValue = function(t) {
            for (var i = this.length; i > 0; i >>= 1) {
                for (var j = 0; j < i; j++) {
                    for (var x = i + j; x < this.length; x = x + i) {
                        var v = this[x];
                        var y = x;
                        while (y >= i && t ? this[y - 1] < v : this[y - i] > v) {
                            this[y] = this[y - i];
                            y = y - i;
                        }
                        this[y] = v;
                    }
                }
            }
            return this;
        };
    },

    String: function() {
        this.trim = function() {
            var _argument = arguments[0] == undefined ? " " : arguments[0];
            if (typeof (_argument) == "string") {
                return this.replace(_argument == " " ? /(^\s*)|(\s*$)/g : new RegExp("(^" + _argument + "*)|(" + _argument + "*$)", "g"), "");
            } else if (typeof (_argument) == "object") {
                return this.replace(_argument, "")
            } else if (typeof (_argument) == "number" && arguments.length >= 1) {
                return arguments.length == 1 ? this.substring(arguments[0]) : this.substring(arguments[0], this.length - arguments[1]);
            }
        };
        this.stripTags = function() {
            return this.replace(/<\/?[^>]+>/gi, '');
        };
        this.cint = function() {
            return this.replace(/\D/g, "") * 1;
        };
        this.camelize = function() {
            return this.replace(/(-\S)/g, function($1) { return $1.toUpperCase().substring(1, 2) });
        };
        this.hasSubString = function(s, f) {
            if (!f) f = "";
            return (f + this + f).indexOf(f + s + f) == -1 ? false : true;
        };
        this.hasSubStrInArr = function() {
            for (var i = 0; i < arguments[0].length; i++) {
                if (this.hasSubString(arguments[0][i])) { return true; }
            }
            return false;
        };
        this.toXMLString = function() {
            var arr = this.split("&");
            var str = new StringBuffer();
            for (var i = 0, len = arr.length; i < len; i++) {
                var item = arr[i].split("=");
                str.append("<" + item[0] + "><![CDATA[" + item[1] + "]]></" + item[0] + ">");
            }
            var rootStr = arguments[0] ? arguments[0] : "root";
            return "<" + rootStr + ">" + str.toString() + "</" + rootStr + ">";
        };
        this.format = function() {
            var p = arguments;
            return this.replace(/(\{\d+\})/g, function() {
                return p[arguments[0].replace(/\D/g, "")];
            });
        };
        this.uniq = function() {
            var arr = this.split("");
            var obj = {};
            for (var i = 0, j; j = arr[i]; i++) {
                obj[j] = i;
            }
            var s = [];
            for (var key in obj) {
                s[obj[key]] = key;
            }
            return s.join("");
        };
    },
    Function: function() {
        this.bind = function() {
            var __method = this, args = $A(arguments), object = args.shift();
            return function() {
                return __method.apply(object, args.concat($A(arguments)));
            }
        };
    },
    StringBuffer: function() {
        this.append = function() { this.data.push(arguments[0]); return this };
        this.toString = function() { return this.data.join(arguments[0] || "") };
        this.length = function() { return this.data.length };
        this.clear = function() { this.data.length = 0; return this; }
    },
    NameSpace: function() {
        this.copyChild = function(ns) {
            for (var key in ns) {
                this[key] = ns[key];
            }
            return this;
        };
    }
};

$._Method.Array.apply(Array.prototype);
$._Method.String.apply(String.prototype);
$._Method.Function.apply(Function.prototype);
$._Method.StringBuffer.apply(StringBuffer.prototype);
$._Method.NameSpace.apply(NameSpace.prototype);

$.Browse = {
    isIE: function() { return navigator.userAgent.hasSubString("MSIE"); },
    isFF: function() { return navigator.userAgent.hasSubString("Firefox"); },
    isOpera: function() { return navigator.userAgent.hasSubString("Opera") },
    isSafari: function() { return navigator.userAgent.hasSubString("Safari"); },
    isGecko: function() { return navigator.userAgent.hasSubString("Gecko"); },
    IEVer: function() { return $.Browse.isIE() ? parseInt(navigator.userAgent.split(";")[1].trim().split(" ")[1]) : 0; }
};
$(document);

var Ajax = {
    xmlhttp: function() {
        var obj = null;
        try {
            obj = new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e) {
            try {
                obj = new ActiveXObject('Microsoft.XMLHTTP');
            } catch (e) {
                obj = new XMLHttpRequest();
            }
        }
        return Ajax.xmlObjCache = obj;
    }, xmlObjCache: null
};
Ajax.Request = function() {
    if (arguments.length < 2) return;
    var para = { asynchronous: true, method: "GET", parameters: "" };
    for (var key in arguments[1]) {
        para[key] = arguments[1][key];
    }
    var _x = Ajax.xmlhttp(); //Ajax.xmlObjCache || 
    var _url = arguments[0];
    if (para["parameters"].length > 0) para["parameters"] += '&_=';
    if (para["method"].toUpperCase() == "GET") _url += (_url.match(/\?/) ? '&' : '?') + para["parameters"];
    _x.open(para["method"].toUpperCase(), _url, para["asynchronous"]);
    _x.onreadystatechange = Ajax.onStateChange.bind(_x, para);
    if (para["method"].toUpperCase() == "POST") _x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    for (var ReqHeader in para["setRequestHeader"]) {
        _x.setRequestHeader(ReqHeader, para["setRequestHeader"][ReqHeader]);
    }
    _x.send(para["method"].toUpperCase() == "POST" ? (para["postBody"] ? para["postBody"] : para["parameters"]) : null);
    return _x;
};
Ajax.onStateChange = function(para) {
    if (this.readyState == 4) {
        if (this.status == 200)
            para["onComplete"] ? para["onComplete"](this) : "";
        else {
            para["onError"] ? para["onError"](this) : "";
        }
    }
};
$.Ajax = {
    Request: function(url, _method, para, complete, error) { return Ajax.Request(url, { method: _method || "get", parameters: para || "", onComplete: complete, onError: error }); },
    get: function(url, complete, error) { return $.Ajax.Request(url + (url.indexOf("?") == -1 ? "?" : "&") + Math.random(), "get", "", complete, error); },
    post: function(url, para, complete, error) { return $.Ajax.Request(url, "post", para, complete, error); },
    postXML: function(url, xmlString, complete, error) { return myAjax = new Ajax.Request(url, { method: "post", postBody: xmlString, setRequestHeader: { "content-Type": "text/xml" }, onComplete: complete, onError: error }); },
    update: function(url, id) { return $.Ajax.Request(url, (arguments[2] ? "post" : "get"), (arguments[2] ? arguments[2] : Math.random()), function(x) { if ("INPUT,SELECT,BUTTON,TEXTAREA".hasSubString($(id).tagName, ",")) { $(id).value = x.responseText; } else { $(id).innerHTML = x.responseText; } }); }
};
$.Cookies = {
    get: function(n) {
        var dc = "; " + document.cookie + "; ";
        var coo = dc.indexOf("; " + n + "=");
        if (coo != -1) {
            var s = dc.substring(coo + n.length + 3, dc.length);
            return unescape(s.substring(0, s.indexOf("; ")));
        } else {
            return null;
        }
    },
    set: function(name, value, expires, path, domain, secure) {
        var expDays = expires * 24 * 60 * 60 * 1000;
        var expDate = new Date();
        expDate.setTime(expDate.getTime() + expDays);
        var expString = expires ? "; expires=" + expDate.toGMTString() : "";
        var pathString = "; path=" + (path || "/");
        var domain = domain ? "; domain=" + domain : "";
        document.cookie = name + "=" + escape(value) + expString + domain + pathString + (secure ? "; secure" : "");
    },
    del: function(n) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval = this.get(n);
        if (cval != null) document.cookie = n + "=" + cval + ";expires=" + exp.toGMTString();
    }
};
$.Form = function(n) {
    var f = typeof n == "string" ? document.forms[n] : n;
    $.Form._Method.apply(f);
    return f;
};
$.Form._Method = function() {
    this.serialize = function(obj) {
        var arr = this.elements;
        var elem = {};
        for (var i = 0, j; j = arr[i]; i++) {
            if (j.disabled || !j.name) { continue; }
            if (j.type && j.type.toLowerCase().hasSubStrInArr(["radio", "checkbox"]) && !j.checked) { continue; }
            var na = j.name.toLowerCase();
            if (typeof elem[na] == "undefined") {
                elem[na] = [];
            }
            elem[na].push($E(j.value));
        }
        return $.Form.serialize(obj, elem);
    };
};
$.Form.serialize = function(obj) {
    var elem = arguments[1] || {};
    for (var key in obj) {
        var na = key.toLowerCase();
        if (typeof elem[na] == "undefined") {
            elem[na] = [];
        }
        elem[na].push($E(obj[key]));
    }
    var para = new StringBuffer();
    for (var name in elem) {
        for (var i = 0; i < elem[name].length; i++) {
            para.append(name + "=" + elem[name][i]);
        }
    }
    return para.toString("&");
};

$.Request = function(paras) {
    var url = location.search;
    if (!url.hasSubString("?")) { return ""; } else { url = url.substring(1); };
    var obj = {};
    url.split("&").each(function(p) {
        var k = p.split("=");
        var n = k[0].toLowerCase();
        obj[n] = k[1] || "";
    });
    return obj[paras.toLowerCase()] || "";
};
$.Redirect = function(url, paraStr) {
    if (!paraStr) {
        setTimeout(function() { location.href = url; }, 10);
        return;
    }
    var obj = {};
    if (url.indexOf("?") != -1) {
        var s = url.substring(url.indexOf("?") + 1).split("&");
        for (var i = 0; i < s.length; i++) {
            var j = s[i].split("=");
            obj[j[0].toString().toLowerCase()] = j[1] || "";
        }
    }
    var t = paraStr.split("&");
    for (var i = 0; i < t.length; i++) {
        var j = t[i].split("=");
        obj[j[0].toString().toLowerCase()] = j[1] || "";
    }
    var str = [];
    for (var p in obj) {
        str.push(p + "=" + obj[p]);
    }
    setTimeout(function() { location.href = url.substring(0, url.indexOf("?")) + "?" + str.join("&"); }, 10);
};
$.Import = function(url) {
    var myAjax = new Ajax.Request(
		url,
		{
		    asynchronous: false,
		    onComplete: function(x) {
		        var js = document.createElement("script");
		        js.type = "text/javascript";
		        js.defer = "defer";
		        js.text = x.responseText;
		        document.getElementsByTagName("head")[0].appendChild(js);
		    },
		    onError: function(x) {
		        alert("Loading script file occur an error:" + x.statusText);
		    }
		}
	);
};


$.DOMReady = function(f) {
    $.DOMReady._methodArgument = f;
    return $.DOMReady.checkReady();
};
$.DOMReady.checkReady = function() {
    if (document && document.getElementsByTagName && document.getElementById && document.body) {
        return $.DOMReady._methodArgument();
    }
    setTimeout("$.DOMReady.checkReady()", 10);
    return null;
}

function $A(list) {
    var arr = [];
    for (var i = 0, len = list.length; i < len; i++) {
        arr[i] = list[i];
    }
    return arr;
};
function $D(str) { return decodeURIComponent(str); };
function $E(str) { return encodeURIComponent(str); };
function $V(id) { return $(id) ? ($(id).tagName.hasSubStrInArr(["INPUT", "TEXTAREA", "SELECT", "BUTTON"]) ? $(id).value : $(id).innerHTML) : ""; };
window.recycler = (function() { var t = document.createElement('div'); t.id = "recycler"; return t; })();

function checkall(form, prefix, checkall) {
	var checkall = checkall ? checkall : 'chkall';
	for(var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if(e.name && e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {
			e.checked = form.elements[checkall].checked;
		}
	}
}

function doane(event) {
	e = event ? event : window.event;
	if(is_ie) {
		e.returnValue = false;
		e.cancelBubble = true;
	} else if(e) {
		e.stopPropagation();
		e.preventDefault();
	}
}

function fetchCheckbox(cbn) {
	return $(cbn) && $(cbn).checked == true ? 1 : 0;
}

function getcookie(name) {
	var cookie_start = document.cookie.indexOf(name);
	var cookie_end = document.cookie.indexOf(";", cookie_start);
	return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}

function thumbImg(obj) {
	var zw = obj.width;
	var zh = obj.height;
	if(is_ie && zw == 0 && zh == 0) {
		var matches
		re = /width=(["']?)(\d+)(\1)/i
		matches = re.exec(obj.outerHTML);
		zw = matches[2];
		re = /height=(["']?)(\d+)(\1)/i
		matches = re.exec(obj.outerHTML);
		zh = matches[2];
	}
	obj.resized = true;
	obj.style.width = zw + 'px';
	obj.style.height = 'auto';
	if(obj.offsetHeight > zh) {
		obj.style.height = zh + 'px';
		obj.style.width = 'auto';
	}
	if(is_ie) {
		var imgid = 'img_' + Math.random();
		obj.id = imgid;
		setTimeout('try {if ($(\''+imgid+'\').offsetHeight > '+zh+') {$(\''+imgid+'\').style.height = \''+zh+'px\';$(\''+imgid+'\').style.width = \'auto\';}} catch(e){}', 1000);
	}
}

function in_array(needle, haystack) {
	if(typeof needle == 'string' || typeof needle == 'number') {
		for(var i in haystack) {
			if(haystack[i] == needle) {
					return true;
			}
		}
	}
	return false;
}

function setcopy(text, alertmsg){
	if(is_ie) {
		clipboardData.setData('Text', text);
		alert(alertmsg);
	} else if(prompt('Press Ctrl+C Copy to Clipboard', text)) {
		alert(alertmsg);
	}
}

function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}

function mb_strlen(str) {
	var len = 0;
	for(var i = 0; i < str.length; i++) {
		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (/*charset == 'utf-8' ? 3 : 2*/3) : 1;
	}
	return len;
}

function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {
	var expires = new Date();
	expires.setTime(expires.getTime() + seconds);
	document.cookie = escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; expires=' + expires.toLocaleString() : '')
		+ (path ? '; path=' + path : '/')
		+ (domain ? '; domain=' + domain : '')
		+ (secure ? '; secure' : '');
}

function strlen(str) {
	return (is_ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}

function updatestring(str1, str2, clear) {
	str2 = '_' + str2 + '_';
	return clear ? str1.replace(str2, '') : (str1.indexOf(str2) == -1 ? str1 + str2 : str1);
}

function toggle_collapse(objname, noimg) {
	var obj = $(objname);
	obj.style.display = obj.style.display == '' ? 'none' : '';
	if(!noimg) {
		var img = $(objname + '_img');
		img.src = img.src.indexOf('_yes.gif') == -1 ? img.src.replace(/_no\.gif/, '_yes\.gif') : img.src.replace(/_yes\.gif/, '_no\.gif')
	}
	var collapsed = getcookie('vm_collapse');
	collapsed =  updatestring(collapsed, objname, !obj.style.display);
	setcookie('vm_collapse', collapsed, (collapsed ? 86400 * 30 : -(86400 * 30 * 1000)));
}

function trim(str) {
	return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
}

/*
function updateseccode() {
	type = seccodedata[2];
	var rand = Math.random();
	if(type < 2) {
		$('seccodeimage').innerHTML = '<img id="seccode" onclick="updateseccode()" width="' + seccodedata[0] + '" height="' + seccodedata[1] + '" src="seccode.php?update=' + rand + '" class="absmiddle" alt="" />';
	} else {
		$('seccodeimage').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + seccodedata[0] + '" height="' + seccodedata[1] + '" align="middle">'
			+ '<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="seccode.php?update=' + rand + '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" />'
			+ '<embed src="seccode.php?update=' + rand + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="' + seccodedata[0] + '" height="' + seccodedata[1] + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	}
}

function updatesecqaa() {
	var x = new Ajax();
	x.get('ajax.php?action=updatesecqaa&inajax=1', function(s) {
		$('secquestion').innerHTML = s;
	});
}
*/

function _attachEvent(obj, evt, func) {
	if(obj.addEventListener) {
		obj.addEventListener(evt, func, false);
	} else if(obj.attachEvent) {
		obj.attachEvent("on" + evt, func);
	}
}

function scrollHiddenDiv(div, scrollwidth)
{
	div.scrollLeft += scrollwidth;
}

function findtags(parentobj, tag) {
	if(!isUndefined(parentobj.getElementsByTagName)) {
		return parentobj.getElementsByTagName(tag);
	} else if(parentobj.all && parentobj.all.tags) {
		return parentobj.all.tags(tag);
	} else {
		return null;
	}
}

function getQueryString(queryname) {
    var qKeys = {};
    var re = /[?&]([^=]+)(?:=([^&]*))?/g;
    var matchInfo;
    while(matchInfo = re.exec(location.search)){
	    qKeys[matchInfo[1]] = matchInfo[2];
    }
    return typeof(qKeys[queryname])=='undefined'?'':qKeys[queryname];
}

function getUserid()
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		// a name alue pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		for(var j = 0; j < aCrumb.length; j++)
		{
			if ("userid" == aCrumb[j])
			{
				return aCrumb[j+1].split("&")[0];
			}
		}
	}
	// a cookie with the requested name does not exist
	return null;
}

function getCSSRule(ruleName, deleteFlag) {               // Return requested style obejct
   ruleName=ruleName.toLowerCase();                       // Convert test string to lower case.
   if (document.styleSheets) {                            // If browser can play with stylesheets
      for (var i=0; i<document.styleSheets.length; i++) { // For each stylesheet
         var styleSheet=document.styleSheets[i];          // Get the current Stylesheet
         var ii=0;                                        // Initialize subCounter.
         var cssRule=false;                               // Initialize cssRule. 
         do {                                             // For each rule in stylesheet
            if (styleSheet.cssRules) {                    // Browser uses cssRules?
               cssRule = styleSheet.cssRules[ii];         // Yes --Mozilla Style
            } else {                                      // Browser usses rules?
               cssRule = styleSheet.rules[ii];            // Yes IE style. 
            }                                             // End IE check.
            if (cssRule)  {                               // If we found a rule...
               if (cssRule.selectorText.toLowerCase()==ruleName) { //  match ruleName?
                  if (deleteFlag=='delete') {             // Yes.  Are we deleteing?
                     if (styleSheet.cssRules) {           // Yes, deleting...
                        styleSheet.deleteRule(ii);        // Delete rule, Moz Style
                     } else {                             // Still deleting.
                        styleSheet.removeRule(ii);        // Delete rule IE style.
                     }                                    // End IE check.
                     return true;                         // return true, class deleted.
                  } else {                                // found and not deleting.
                     return cssRule;                      // return the style object.
                  }                                       // End delete Check
               }                                          // End found rule name
            }                                             // end found cssRule
            ii++;                                         // Increment sub-counter
         } while (cssRule)                                // end While loop
      }                                                   // end For loop
   }                                                      // end styleSheet ability check
   return false;                                          // we found NOTHING!
}                                                         // end getCSSRule 

function killCSSRule(ruleName) {                          // Delete a CSS rule   
   return getCSSRule(ruleName,'delete');                  // just call getCSSRule w/delete flag.
}                                                         // end killCSSRule

function addCSSRule(ruleName) {                           // Create a new css rule
   if (document.styleSheets) {                            // Can browser do styleSheets?
      if (!getCSSRule(ruleName)) {                        // if rule doesn't exist...
         if (document.styleSheets[0].addRule) {           // Browser is IE?
            document.styleSheets[0].addRule(ruleName, null,0);      // Yes, add IE style
         } else {                                         // Browser is IE?
            document.styleSheets[0].insertRule(ruleName+' { }', 0); // Yes, add Moz style.
         }                                                // End browser check
      }                                                   // End already exist check.
   }                                                      // End browser ability check.
   return getCSSRule(ruleName);                           // return rule we just created.
} 

function display(id) {
	$(id).style.display = $(id).style.display == '' ? 'none' : '';
}

function display_opacity(id, n) {
	if(!$(id)) {
		return;
	}
	if(n >= 0) {
		n -= 10;
		$(id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + n + ')';
		$(id).style.opacity = n / 100;
		setTimeout('display_opacity(\'' + id + '\',' + n + ')', 50);
	} else {
		$(id).style.display = 'none';
		$(id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
		$(id).style.opacity = 1;
	}
}



function showhint(iconid, str)
{
	var imgUrl='../images/hint.gif';
	if (iconid != 0)
	{
		imgUrl = '../images/warning.gif';
	}
	document.write('<div style="background:url(' + imgUrl + ') no-repeat 20px 10px;border:1px dotted #DBDDD3; background-color:#FDFFF2; margin-bottom:10px; padding:10px 10px 10px 56px; text-align: left; font-size: 12px;">');
	document.write(str + '</div><div style="clear:both;"></div>');
}

function showloadinghint(divid, str)
{
	if (divid=='')
	{
		divid='PostInfo';
	}
	document.write('<div id="' + divid + ' " style="display:none;position:relative;border:1px dotted #DBDDD3; background-color:#FDFFF2; margin:auto;padding:10px" width="90%"  ><img border="0" src="../images/ajax_loading.gif" /> ' + str + '</div>');
}


function CheckByName(form,tname,checked)
{
    for (var i=0;i<form.elements.length;i++)
    {
        var e = form.elements[i];
        if(e.name == tname)
        {
            e.checked = checked;
        }
    }
}


function CheckAll(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
        var e = form.elements[i];
        if (e.type=="checkbox" && e.name != 'chkall' && e.name !='deleteMode')
        {
           e.checked = form.chkall.checked;
        }
    }
}

//function SH_SelectOne()
//{
//	var obj = window.event.srcElement;
//	if( obj.checked == false)
//	{
//		document.getElementById('chkall').checked = obj.chcked;
//		
//	}
//}


  function   selectall(s)
  {   
  var   obj=document.getElementsByTagName("input");   
  for(i=0;i<obj.length;i++)
  {
  if(obj[i].id=="id"+s)   
 {
  obj[i].checked=window.event.srcElement.checked ; 
 }
  }   
}


function SH_SelectOne(obj)
{
	//var obj = window.event.srcElement;
	if( obj.checked == false)
	{
		document.getElementById('chkall').checked = obj.chcked;
	}
}


//function togetherpi(obj)
//{
//if(document.getElementById("id"+obj).checked == true)
//{
//document.getElementById("pid"+obj).checked =true;
//else
//document.getElementById("pid"+obj).checked =false;
//}



var xmlhttp;
   
function getReturn(Url)  //提交为aspx,aspx页面路径, 返回页面的值
{
    if(typeof XMLHttpRequest != "undefined")
    {
        xmlhttp = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        var versions = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
        for(var i = 0 ; i < versions.length; i++)
        {
            try
            {
                xmlhttp = new ActiveXObject(versions[i]);
                break;
            }
            catch(E)
            {
            }
        }
    }
        
    try 
    {
        xmlhttp.open('GET',Url,false);   
        xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
        xmlhttp.send(null);    
        
        if((xmlhttp.readyState == 4)&&(xmlhttp.status == 200))
        {
            return xmlhttp.responseText;
        }
        else
        {
           return null;
        }
    }
    catch (e) 
    {  
         alert("你的浏览器不支持XMLHttpRequest对象, 请升级"); 
    }

    return null;
}
       

function isMaxLen(o)
{
	var nMaxLen=o.getAttribute? parseInt(o.getAttribute("maxlength")):"";
	if(o.getAttribute && o.value.length>nMaxLen)
	{
		o.value=o.value.substring(0,nMaxLen)
	}
}
    
/*
function Pause(obj,iMinSecond){ 
 if (window.eventList==null) window.eventList=new Array(); 
 var ind=-1; 
 for (var i=0;i<window.eventList.length;i++){ 
  if (window.eventList[i]==null) { 
   window.eventList[i]=obj; 
   ind=i; 
   break; 
  } 
 } 
  
 if (ind==-1){ 
  ind=window.eventList.length; 
  window.eventList[ind]=obj; 
 } 
 setTimeout("GoOn(" + ind + ")",iMinSecond); 
} 


function GoOn(ind){ 
 var obj=window.eventList[ind]; 
 window.eventList[ind]=null; 
 if (obj.NextStep) obj.NextStep(); 
 else obj(); 
} 


function Test(name){ 
 alert(name); 
 Pause(this,10000);//调用暂停函数 
 this.NextStep=function hello(name){ 
  alert('hello'+name); 
} 
} 

Test('dai');
*/

//权限按行选函数
function selectRow(rowId,check)
{
	document.getElementById("viewperm" + rowId).checked = check;
	document.getElementById("postperm" + rowId).checked = check;
	document.getElementById("replyperm" + rowId).checked = check;
	document.getElementById("getattachperm" + rowId).checked = check;
	document.getElementById("postattachperm" + rowId).checked = check;
}
//权限按列选函数
function seleCol(colPerfix,check)
{
	var obj;
	var i = 1;
	while(true)
	{
		obj = document.getElementById(colPerfix + i);
		if(obj == null) break;
		obj.checked = check;
		i++;
	}
}
   

function changeDeleteModeState(item,form)
{
	switch(item)
	{
		case 1:
			document.getElementById("chkall").disabled = false;
			document.getElementById("deleteNum").disabled = document.getElementById("deleteFrom_deleteFrom").disabled = true;
			enableCheckBox(false,form);
			document.getElementById("deleteNum").value = "";
			document.getElementById("deleteFrom_deleteFrom").value = "";
	        Check(form);
			break;
		case 2:
			document.getElementById("deleteNum").disabled = false;
			document.getElementById("chkall").disabled = document.getElementById("deleteFrom_deleteFrom").disabled = true;
			enableCheckBox(true,form);
			document.getElementById("chkall").checked = false;			
			document.getElementById("deleteFrom_deleteFrom").value = "";
			DeleteMode2SetStatus();
			break;
		case 3:
			document.getElementById("deleteFrom_deleteFrom").disabled = false;
			document.getElementById("chkall").disabled = document.getElementById("deleteNum").disabled = true;
			enableCheckBox(true,form);
			document.getElementById("chkall").checked = false;			
			document.getElementById("deleteNum").value = "";
			DeleteMode3SetStatus();
			break;
	}
}  

function enableCheckBox(b,form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.type == "checkbox")
		{
			e.disabled = b;
			e.checked = false;
		}
	}
} 

function isie()
{
   if(navigator.userAgent.toLowerCase().indexOf('msie') != -1)
   {
       return true;
   }
   else
   {
       return false;
   }
}  


//显示提示层
function showhintinfo(obj, objleftoffset,objtopoffset, title, info , objheight, showtype ,objtopfirefoxoffset)
{
   
   var p = getposition(obj);
   
   if((showtype==null)||(showtype =="")) 
   {
       showtype =="up";
   }
   document.getElementById('hintiframe'+showtype).style.height= objheight + "px";
   document.getElementById('hintinfo'+showtype).innerHTML = info;
   document.getElementById('hintdiv'+showtype).style.display='block';
   
   if(objtopfirefoxoffset != null && objtopfirefoxoffset !=0 && !isie())
   {
        document.getElementById('hintdiv'+showtype).style.top=p['y']+parseInt(objtopfirefoxoffset)+"px";
   }
   else
   {
        if(objtopoffset == 0)
        { 
			if(showtype=="up")
			{
				 document.getElementById('hintdiv'+showtype).style.top=p['y']-document.getElementById('hintinfo'+showtype).offsetHeight-40+"px";
			}
			else
			{
				 document.getElementById('hintdiv'+showtype).style.top=p['y']+obj.offsetHeight+5+"px";
			}
        }
        else
        {
			document.getElementById('hintdiv'+showtype).style.top=p['y']+objtopoffset+"px";
        }
   }
   document.getElementById('hintdiv'+showtype).style.left=p['x']+objleftoffset+"px";
}



//隐藏提示层
function hidehintinfo()
{
    document.getElementById('hintdivup').style.display='none';
    document.getElementById('hintdivdown').style.display='none';
}



//得到字符串长度
function getLen( str) 
{
   var totallength=0;
   
   for (var i=0;i<str.length;i++)
   {
     var intCode=str.charCodeAt(i);   
     if (intCode>=0&&intCode<=128)
     {
        totallength=totallength+1; //非中文单个字符长度加 1
	 }
     else
     {
        totallength=totallength+2; //中文字符长度则加 2
     }
   } 
   return totallength;
}   
   


function getposition(obj)
{
	var r = new Array();
	r['x'] = obj.offsetLeft;
	r['y'] = obj.offsetTop;
	while(obj = obj.offsetParent)
	{
		r['x'] += obj.offsetLeft;
		r['y'] += obj.offsetTop;
	}
	return r;
}

  

function cancelbubble(obj)
{
    //<textarea style="width:400px"></textarea>
    //var log = document.getElementsByTagName('textarea')[0];
	var all = obj.getElementsByTagName('*');
	
	for (var i = 0 ; i < all.length; i++)
	{
	    //log.value +=  all[i].nodeName +":" +all[i].id + "\r\n";
		all[i].onmouseover = function(e)
		{
    		if (e) //停止事件冒泡
	    	    e.stopPropagation();
		    else
			    window.event.cancelBubble = true;
			
			obj.style.display='block';
			//this.style.border = '1px solid white';
			//log.value = '鼠标现在进入的是： ' + this.nodeName + "_" + this.id;
		};
		
		all[i].onmouseout = function(e)
		{
		    if (e) //停止事件冒泡
			    e.stopPropagation();
		    else
			    window.event.cancelBubble = true;
			
	 
			if(this.nodeName == "DIV")
			{
			    obj.style.display='none';
			}
//			else
//			{
//			    obj.style.display='none';
//			}
			//this.style.border = '1px solid white';
			//log.value = '鼠标现在离开的是：' + this.nodeName + "_" + this.id;
	    };
	}

}

//当指定name的复选框选中时，激活相应的按钮
//arguments[0]为指定form，arguments[1]为复选框的name，arguments[2]～arguments[arguments.length - 1]为要激活的按钮
function checkedEnabledButton()
{
    for (var i = 0; i < arguments[0].elements.length; i++)
    {
        var e = arguments[0].elements[i];
        if (e.name == arguments[1] && e.checked)
        {
            for(var j = 2; j < arguments.length; j++)
            {
                document.getElementById(arguments[j]).disabled = false;
            }
            return;
        }
    }
    for(var j = 2; j < arguments.length; j++)
    {
        document.getElementById(arguments[j]).disabled = true;
    }
}

function isNumber(str)
{
    return (/^[+|-]?\d+$/.test(str));
}

// 关闭窗口，不提示
function Close() {
    var ua = navigator.userAgent
    var ie = navigator.appName == "Microsoft Internet Explorer" ? true : false
    if (ie) {
        var IEversion = parseFloat(ua.substring(ua.indexOf("MSIE ") + 5, ua.indexOf(";", ua.indexOf("MSIE "))))
        if (IEversion < 5.5) {
            var str = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'
            str += '<param name="Command" value="Close"></object>';
            document.body.insertAdjacentHTML("beforeEnd", str);
            document.all.noTipClose.Click();
        }
        else {
            window.opener = null;
            window.open('', '_self', ''); //for IE7
            window.close();
        }
    }
    else {
        window.close()
    }
}
// 弹出窗口
function FullWinOpen(url) {
    var Cwin = window.open(url, '', 'fullscreen'); //fullscreen
    Cwin.resizeTo(screen.availWidth, screen.availHeight);
}

function MouseCursor(obj) {
    if (is_ie)
        obj.style.cursor = 'hand';
    else
        obj.style.cursor = 'pointer';
}